package com.example.chuntiao.cophook.adapter;

import com.example.chuntiao.cophook.beans.Person;

import java.util.Comparator;

/**
 * Created by chuntiao on 17-7-19.
 */

public class CompPerson implements Comparator<Person> {

    @Override
    public int compare(Person p1, Person p2) {
        String left = p1.getPyOfHomeName();
        String right = p2.getPyOfHomeName();

        if (left.contains(right) && right.contains(left))
            return 0;
        else if (left.contains(right))
            return 1;
        else if (right.contains(left))
            return -1;

        for (int i = 0; i < left.length() && i < right.length(); i++)
            if (left.charAt(i) > right.charAt(i))
                return 1;
            else if (left.charAt(i) < right.charAt(i))
                return -1;

        return 0;
    }
}



